﻿
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace hutil {
    public class TaskUtil {
        private static Object lockObj = new Object();
        private  const int arang = 0x7FFFFF;
        private static int TaskNo=-1;
        public static int getTaskNo() {
            lock(lockObj) {
                if(TaskNo == -1) {
                    TaskNo = getTime();
                } else {
                    TaskNo++;
                  int minTime =  getTime()-3600;
                    if(minTime < 0) {
                        minTime = minTime + arang;
                    }
                    if(TaskNo < minTime) {
                        TaskNo = minTime;
                    }
                    if(TaskNo >= arang) {
                        TaskNo -= arang;
                    }
                }
                return TaskNo + 1000000000;
            }
        }
        static  private  int  getTime() {
            long seconds = System.DateTime.Now.Ticks / HUtil.ticksSecRate;
            int Task = (int)(seconds & arang);
            return Task;
        }
      
     }
}
